//
//  ZZFCurrentUser.m
//  Pods
//
//  Created by quheng on 2017/8/31.
//
//

#import "BZUCCurrentUser.h"
#import "BZUCUserModel.h"
#import <BZDataBaseSDK/BZDataBaseSDK.h>



static BZUCCurrentUser *currentUser = nil;

@implementation BZUCCurrentUser

+ (instancetype)shareInstance{

    static dispatch_once_t onceToken;
    
    dispatch_once(&onceToken, ^{
    
        currentUser = [[self alloc]init];
        
    });
    
    return currentUser;
}

- (BZUCUserModel *)userModel{

    if (!_userModel) {
        
        NSError *error = nil;
        NSDictionary *dict =  [BZDataBaseManager selectDataBaseSync:@"bzuc"
                                                          tableName:@"uctable"
                                                    sqlConditionStr:nil
                                                           outError:&error];
       _userModel = [MTLJSONAdapter modelOfClass:[BZUCUserModel class] fromJSONDictionary:dict error:&error];
        //暂时注释
//        NSTimeInterval now = [[NSDate date] timeIntervalSince1970];
//        if ([_userModel.expireTime longLongValue] < now) {
//            _userModel.password = @"";
//        }
    }
    return _userModel;

}


@end
